<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Freeze Row Example</title>
    <style>
        .container {
            position: relative;
            overflow: auto;
            height: 200px;
            /* Set the container height */
        }

        .fixed-header {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            z-index: 1;
            background-color: white;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th,
        td {
            padding: 8px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }

        th {
            position: sticky;
            top: 0;
            background-color: white;
        }
        .fixed-tr{
             position: relative;
            overflow: auto;
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="fixed-header">
            <table>
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Age</th>
                        <th>Address</th>
                    </tr>
                </thead>
            </table>
        </div>
        <table>
            <tbody>
                <tr>
                    <td>Alice</td>
                    <td>28</td>
                    <td>New York No. 1 Lake Park</td>
                </tr>
                <tr>
                    <td>Bob</td>
                    <td>30</td>
                    <td>London No. 1 Lake Park</td>
                </tr>
                <tr>
                    <td>Cathy</td>
                    <td>25</td>
                    <td>Sidney No. 1 Lake Park</td>
                </tr>
                <tr class="fixed-tr">
                    <td class="fixed-td">David</td>
                    <td class="fixed-td">22</td>
                    <td class="fixed-td">Shanghai No. 1 Lake Park</td>
                </tr>
                <tr>
                    <td>Eva</td>
                    <td>24</td>
                    <td>Beijing No. 1 Lake Park</td>
                </tr>
                <tr>
                    <td>Alice</td>
                    <td>28</td>
                    <td>New York No. 1 Lake Park</td>
                </tr>
                <tr>
                    <td>Bob</td>
                    <td>30</td>
                    <td>London No. 1 Lake Park</td>
                </tr>
            </tbody>
        </table>
    </div>

    <script>
        const container = document.querySelector('.container');
        const fixedHeader = document.querySelector('.fixed-header');

        container.addEventListener('scroll', () => {
            fixedHeader.style.transform = `translateY(${container.scrollTop}px)`;
        });
    </script>
</body>

</html>